import axios from "axios"
import cookie from 'js-cookie'

const service = axios.create({
  baseURL: 'http://localhost:9001',
  timeout: 20000
});

// request拦截器
service.interceptors.request.use(
  config => {
    //判断能否从cookie中获取token值
    if (cookie.get('jn_cookie')) {
      // 让每个请求携带自定义token 请根据实际情况自行修改
      config.headers['token'] = cookie.get('jn_cookie')
    }
    return config
  }
);

export default service
